package com.example.driving.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.driving.base.BaseContext;
import com.example.driving.base.BaseFragment;
import com.example.driving.databinding.FragmentMineBinding;
import com.example.driving.model.UserBean;

public class TabMineFragment extends BaseFragment<FragmentMineBinding> {
    private FragmentMineBinding mbinding;

    public static UserBean userBean = null;
    @Override
    public FragmentMineBinding getViewBinding(LayoutInflater inflater, ViewGroup container) {
        mbinding = FragmentMineBinding.inflate(inflater,container,false);
        return mbinding;
    }



    @Override
    public void onStart() {
        super.onStart();
        System.out.println("onstart");
        if (SubjectFragment.infoBean!=null){
            mbinding.tvCountAll.setText(String.valueOf(SubjectFragment.infoBean.getNum_questions()));
            int v =(int) SubjectFragment.infoBean.getAccuracy() * 100;
            mbinding.tvPercentR.setText("正确率"+String.valueOf(v)+"%");

            mbinding.tvMkCount.setText("累计考试"+String.valueOf(SubjectFragment.infoBean.getNum_test()));
            mbinding.tvMkScore.setText(String.valueOf(SubjectFragment.infoBean.getTest_Average()));

        }
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        if (userBean!=null){

            mbinding.login.setText(userBean.getUserAccount());
            BaseContext.setCurrentId(userBean.getId());
        }




    }

    @Override
    protected void initData() {


        mbinding.login.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), UserActivity.class);
            startActivity(intent);

        });

        mbinding.tvKf.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), ChatActivity.class);
            startActivity(intent);
        });

        mbinding.tvYszc.setOnClickListener(v->{
            WebViewActivity.start(instance,"https://www.cbg.cn/privacyPolicy.html");
        });
        mbinding.tvYhxy.setOnClickListener(v -> {
            WebViewActivity.start(instance,
                    "https://admin.qidian.qq.com/template/blue/website/agreement.html");
        });
    }

    @Override
    public void onBaseClick(View v) {

    }
}
